From bced18b3c5b7e3aa3e9f0bb56961d25e5e3d86b8 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Timm=20B=C3=A4der?= Date: Wed, 3 May 2017 19:44:52 +0200 Subject: [PATCH] headerbar: Remove gadget both drawing and sizing are done through GtkWidget now. --- gtk/gtkheaderbar.c | 74 ++++++++-------------------------------------- 1 file changed, 12 insertions(+), 62 deletions(-) diff --git a/gtk/gtkheaderbar.c b/gtk/gtkheaderbar.c index 19d28eda85..60766a458b 100644 --- a/gtk/gtkheaderbar.c +++ b/gtk/gtkheaderbar.c @@ -26,7 +26,6 @@ #include "gtktypebuiltins.h" #include "gtkwidgetprivate.h" #include "gtkcssnodeprivate.h" -#include "gtkcsscustomgadgetprivate.h" #include "gtkwindowprivate.h" #include "gtkwidgetprivate.h" #include "gtkcontainerprivate.h" @@ -83,7 +82,6 @@ struct _GtkHeaderBarPrivate GtkWidget *titlebar_icon; - GtkCssGadget *gadget; guint shows_app_menu : 1; }; @@ -877,26 +875,6 @@ gtk_header_bar_compute_size_for_opposing_orientation (GtkWidget *widget, *natural_size = computed_natural; } -static void -gtk_header_bar_get_content_size (GtkCssGadget *gadget, - GtkOrientation orientation, - gint for_size, - gint *minimum, - gint *natural, - gint *minimum_baseline, - gint *natural_baseline, - gpointer unused) -{ - GtkWidget *widget = gtk_css_gadget_get_owner (gadget); - - if (for_size < 0) - gtk_header_bar_get_size (widget, orientation, minimum, natural); - else if (orientation == GTK_ORIENTATION_HORIZONTAL) - gtk_header_bar_compute_size_for_orientation (widget, for_size, minimum, natural); - else - gtk_header_bar_compute_size_for_opposing_orientation (widget, for_size, minimum, natural); -} - static void gtk_header_bar_measure (GtkWidget *widget, GtkOrientation orientation, @@ -906,13 +884,12 @@ gtk_header_bar_measure (GtkWidget *widget, int *minimum_baseline, int *natural_baseline) { - GtkHeaderBarPrivate *priv = gtk_header_bar_get_instance_private (GTK_HEADER_BAR (widget)); - - gtk_css_gadget_get_preferred_size (priv->gadget, - orientation, - for_size, - minimum, natural, - minimum_baseline, natural_baseline); + if (for_size < 0) + gtk_header_bar_get_size (widget, orientation, minimum, natural); + else if (orientation == GTK_ORIENTATION_HORIZONTAL) + gtk_header_bar_compute_size_for_orientation (widget, for_size, minimum, natural); + else + gtk_header_bar_compute_size_for_opposing_orientation (widget, for_size, minimum, natural); } static void @@ -921,25 +898,8 @@ gtk_header_bar_size_allocate (GtkWidget *widget, { GtkHeaderBarPrivate *priv = gtk_header_bar_get_instance_private (GTK_HEADER_BAR (widget)); GtkAllocation clip; - - gtk_widget_set_allocation (widget, allocation); - - gtk_css_gadget_allocate (priv->gadget, allocation, gtk_widget_get_allocated_baseline (widget), &clip); - - gtk_widget_set_clip (widget, &clip); -} - -static void -gtk_header_bar_allocate_contents (GtkCssGadget *gadget, - const GtkAllocation *allocation, - int baseline, - GtkAllocation *out_clip, - gpointer unused) -{ - GtkWidget *widget = gtk_css_gadget_get_owner (gadget); GtkWidget *title_widget; GtkHeaderBar *bar = GTK_HEADER_BAR (widget); - GtkHeaderBarPrivate *priv = gtk_header_bar_get_instance_private (bar); GtkRequestedSize *sizes; gint width, height; gint nvis_children; @@ -1138,7 +1098,7 @@ gtk_header_bar_allocate_contents (GtkCssGadget *gadget, gtk_widget_size_allocate (child->widget, &child_allocation); gtk_widget_get_clip (child->widget, &child_clip); - gdk_rectangle_union (&child_clip, out_clip, out_clip); + gdk_rectangle_union (&child_clip, &clip, &clip); next: i++; @@ -1177,7 +1137,7 @@ gtk_header_bar_allocate_contents (GtkCssGadget *gadget, { gtk_widget_size_allocate (title_widget, &child_allocation); gtk_widget_get_clip (title_widget, &child_clip); - gdk_rectangle_union (&child_clip, out_clip, out_clip); + gdk_rectangle_union (&child_clip, &clip, &clip); } child_allocation.y = allocation->y; @@ -1193,7 +1153,7 @@ gtk_header_bar_allocate_contents (GtkCssGadget *gadget, child_allocation.width = start_width - priv->spacing; gtk_widget_size_allocate (priv->titlebar_start_box, &child_allocation); gtk_widget_get_clip (priv->titlebar_start_box, &child_clip); - gdk_rectangle_union (&child_clip, out_clip, out_clip); + gdk_rectangle_union (&child_clip, &clip, &clip); } if (priv->titlebar_end_box) @@ -1206,8 +1166,10 @@ gtk_header_bar_allocate_contents (GtkCssGadget *gadget, child_allocation.width = end_width - priv->spacing; gtk_widget_size_allocate (priv->titlebar_end_box, &child_allocation); gtk_widget_get_clip (priv->titlebar_end_box, &child_clip); - gdk_rectangle_union (&child_clip, out_clip, out_clip); + gdk_rectangle_union (&child_clip, &clip, &clip); } + + gtk_widget_set_clip (widget, &clip); } /** @@ -1467,8 +1429,6 @@ gtk_header_bar_finalize (GObject *object) g_free (priv->subtitle); g_free (priv->decoration_layout); - g_clear_object (&priv->gadget); - G_OBJECT_CLASS (gtk_header_bar_parent_class)->finalize (object); } @@ -2019,7 +1979,6 @@ static void gtk_header_bar_init (GtkHeaderBar *bar) { GtkHeaderBarPrivate *priv; - GtkCssNode *widget_node; priv = gtk_header_bar_get_instance_private (bar); @@ -2038,15 +1997,6 @@ gtk_header_bar_init (GtkHeaderBar *bar) init_sizing_box (bar); construct_label_box (bar); - - widget_node = gtk_widget_get_css_node (GTK_WIDGET (bar)); - priv->gadget = gtk_css_custom_gadget_new_for_node (widget_node, - GTK_WIDGET (bar), - gtk_header_bar_get_content_size, - gtk_header_bar_allocate_contents, - NULL, - NULL, - NULL); } static void -- 2.30.2